import os

from spiders.crawer_shipment import get_shipment_info
import time

from project_setting import image_data_path
from crawer_detail import  save_pic
from predict import predict

from utils.http_utils import make_shipment_coookie

from spiders.crawer_shipment import get_shipment_info

from spiders.crawl_webquery import predict_image

def parse_shipment(craw_id):
    request_cookie = make_shipment_coookie()
    base_url = 'https://www.shipmentlink.com/servlet/TUF1_CaptchaUtils?d='
    timestamp = str(int(round(time.time() * 1000)))
    imageurl = base_url + timestamp
    save_pic(imageurl,basepath=image_data_path,request_cookie = request_cookie)
    imagecode = predict_image(os.path.join(image_data_path,'2.jpg'))#predict(img_dir=image_data_path)
    res = get_shipment_info(timestamp, imagecode, craw_id,request_cookie)
    return  res